<?php include dirname(__FILE__).'/common/header.php'; ?>

<?php include dirname(__FILE__).'/common/menu.php'; ?>

var attr = {};
attr.ctrlName = '<?php echo $ctrlName; ?>';


function addIframe(data,i) {
	if(i >= data.length) {
		Ext.get(document.body).unmask();
		return;
	}
	Ext.get(document.body).mask('正在加载第['+(i+1)+'/'+data.length+']用户');
	var elem = document.createElement('iframe');
	elem.src=data[i];
	elem.width = 0;
	elem.height = 0;
	elem.border = 'none';
	elem.style.cssText = 'position:absolute;width:0;height:0;opacity:0.3;z-index:-1;';
	elem.onload = function(e) {
		setTimeout((function(el) {
			return function() {
				document.body.removeChild(el);
				addIframe(data,i+1);
			}
		})(e.target),1000);
	}
	document.body.appendChild(elem);
}


/*
| -------------------------------------------------------------------
|  List Grid
| -------------------------------------------------------------------
*/
list.grid = new ZM.GridPanel({
    url: list.baseUrl + attr.ctrlName+'/getCustomerList',
    tbar:[{
        text:'添加访问',
        cls:'btn-show',
        hidden:!Ext.permission[attr.ctrlName + '/makeAccess'.toLowerCase()],
        handler:function() {
            var win = new ZM.PopUp({
                title:'添加时间设置',
                type:'s',
                items:{
                    xtype:'formpanel',
                    url:list.baseUrl+ attr.ctrlName+'/makeAccess',
                    success:function(res) {
                        ZM.bo.msg('success',res.detail);
                        win.close();
                        addIframe(res.items,0);
                    },
                    items:[{
                        xtype:'numberfield',
                        fieldLabel:'开始位置',
                        name:'start',
                        allowBlank:false
                    },{
                        xtype:'numberfield',
                        fieldLabel:'数量',
                        name:'limit',
                        allowBlank:false
                    }]
                }
            }).show();
        }
    }],
    columns:[
        {header:'ID',dataIndex:'customer_id',filter:{}},
        {header:'头像',width:120,dataIndex:'headimgurl',renderer:ZM.cellImage},
        {header:'昵称',dataIndex:'nickname',filter:{}},
        {header:'openid',dataIndex:'openid',width:200,filter:{}},
        {header:'性别',dataIndex:'sex',filter:{xtype:'combofield',options:[['','全部'],['0','未知'],[1,'男'],[2,'女']]},renderer:function(val) {
            return ZM.id2name(val,[[0,'未知'],[1,'男'],[2,'女']]);
        }},
        {header:'省份',dataIndex:'province'},
        {header:'城市',dataIndex:'city'},
        {header:'国家',dataIndex:'country'}
    ]
});

<?php include dirname(__FILE__).'/common/layout.php'; ?>
list.grid.store.load();
<?php include dirname(__FILE__).'/common/footer.php'; ?>